package com.logback.demo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Method;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Author zqf
 * @Date 2023/3/21 14:47
 * @Description: 反射(获取class对象)
 */
public class ReflectionTest {
    private static final Logger LOGGER = LoggerFactory.getLogger(ReflectionTest.class);

    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException {

        AtomicInteger flag = new AtomicInteger();
        System.out.println("flag = " + flag);
        flag.set(1);
        System.out.println("flag = " + flag.intValue());


        //获取String的class对象
        Class<String> stringClass = String.class;
//        LOGGER.info(String.valueOf(stringClass));
//
//        String name = stringClass.getName();
//        LOGGER.info(name);
//
//
//        Class<?> aClass = Class.forName("com.logback.demo.People");
//        LOGGER.info(String.valueOf(aClass));
//
//
//        ClassLoader classLoader = ReflectionTest.class.getClassLoader();
//        Class<?> loadClass = classLoader.loadClass("com.logback.demo.People");
//        LOGGER.info(String.valueOf(loadClass));
//
//
//        Class<People> peopleClass = People.class;
//        People people = peopleClass.newInstance();
//        people.setAge(10);
//        people.setName("张三");
//        System.out.println("people = " + people.toString());


    }
}
